/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.sql.Date;
import java.sql.Timestamp;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.CascadeType;
import javax.persistence.EmbeddedId;
import javax.persistence.OneToOne;

/**
 *
 * @author Ee Ting
 */
@Entity
public class ProductionRecord implements Serializable {
    
    @EmbeddedId
    ProductionPk pk;
    
    private int producedAmt;
    private Timestamp createdDate;
    @OneToOne(cascade = {CascadeType.PERSIST})
    private SystemUser createdBy;
    
    public ProductionRecord(){}
    
    public void create(String prodDate,String prodID,SystemUser user,int amt)
    {
        ProductionPk pk = new ProductionPk(prodDate,prodID);
        this.setPk(pk);
        this.setCreatedBy(user);
        this.setProducedAmt(amt);  
        java.util.Date tmp = new java.util.Date();
        this.setCreatedDate(new Timestamp(tmp.getTime()));
    }

    public ProductionPk getPk() {
        return pk;
    }

    public void setPk(ProductionPk pk) {
        this.pk = pk;
    }

   
    public SystemUser getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(SystemUser createdBy) {
        this.createdBy = createdBy;
    }

    public Timestamp getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Timestamp createdDate) {
        this.createdDate = createdDate;
    }

    public int getProducedAmt() {
        return producedAmt;
    }

    public void setProducedAmt(int producedAmt) {
        this.producedAmt = producedAmt;
    }
    
}
